]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
Start using MessageTray.Source directly instead of having to subclass it
authorJasper St. Pierre <jstpierre@mecheye.net>
Sat, 8 Oct 2011 22:00:32 +0000 (18:00 -0400)
committerJasper St. Pierre <jstpierre@mecheye.net>
Thu, 17 May 2012 12:32:22 +0000 (08:32 -0400)
For most subclasses, this is a direct swap -- a lot of the time, the
constructor was a blank class that override createNotificationIcon,
and called _setSummaryIcon in _init.

https://bugzilla.gnome.org/show_bug.cgi?id=661236

js/ui/autorunManager.js
js/ui/keyboard.js
js/ui/messageTray.js
js/ui/notificationDaemon.js
js/ui/shellMountOperation.js
js/ui/status/bluetooth.js
js/ui/status/network.js
js/ui/telepathyClient.js
js/ui/windowAttentionHandler.js

index 27d89e894a9fca6c9316c3f74c903e2b159d4184..9fbb26e53004f7c603e501cb29b4c83c5013f176 100644 (file)
@@ -262,12 +262,11 @@ const AutorunResidentSource = new Lang.Class({
     Extends: MessageTray.Source,
 
     _init: function() {
-        this.parent(_("Removable Devices"));
+        this.parent(_("Removable Devices"), 'media-removable', St.IconType.FULLCOLOR);
 
         this._mounts = [];
 
         this._notification = new AutorunResidentNotification(this);
-        this._setSummaryIcon(this.createNotificationIcon());
     },
 
     addMount: function(mount, apps) {
@@ -310,12 +309,6 @@ const AutorunResidentSource = new Lang.Class({
             Main.messageTray.add(this);
             this.pushNotification(this._notification);
         }
-    },
-
-    createNotificationIcon: function() {
-        return new St.Icon ({ icon_name: 'media-removable',
-                              icon_type: St.IconType.FULLCOLOR,
-                              icon_size: this.ICON_SIZE });
     }
 });
 
@@ -500,11 +493,11 @@ const AutorunTransientSource = new Lang.Class({
     Extends: MessageTray.Source,
 
     _init: function(mount, apps) {
-        this.parent(mount.get_name());
-
         this.mount = mount;
         this.apps = apps;
 
+        this.parent(mount.get_name());
+
         this._notification = new AutorunTransientNotification(this);
         this._setSummaryIcon(this.createNotificationIcon());
 
index 1340e7b4074831e135b8ba5480d1c9d57e2a8123..a5cd199832017e18bc766e3e87acdfad0e10921c 100644 (file)
@@ -541,16 +541,8 @@ const KeyboardSource = new Lang.Class({
     Extends: MessageTray.Source,
 
     _init: function(keyboard) {
-        this.parent(_("Keyboard"));
         this._keyboard = keyboard;
-
-        this._setSummaryIcon(this.createNotificationIcon());
-    },
-
-    createNotificationIcon: function() {
-        return new St.Icon({ icon_name: 'input-keyboard',
-                             icon_type: St.IconType.SYMBOLIC,
-                             icon_size: this.ICON_SIZE });
+        this.parent(_("Keyboard"), 'input-keyboard', St.IconType.SYMBOLIC);
     },
 
     handleSummaryClick: function() {
index b3da8c73e4e986e5b3312ea6731d8d08dbe77ef7..c7e34108658dbfa6dbc9812f1fc4a5acb5c49a9c 100644 (file)
@@ -2493,15 +2493,7 @@ const SystemNotificationSource = new Lang.Class({
     Extends: Source,
 
     _init: function() {
-        this.parent(_("System Information"));
-
-        this._setSummaryIcon(this.createNotificationIcon());
-    },
-
-    createNotificationIcon: function() {
-        return new St.Icon({ icon_name: 'dialog-information',
-                             icon_type: St.IconType.SYMBOLIC,
-                             icon_size: this.ICON_SIZE });
+        this.parent(_("System Information"), 'dialog-information', St.IconType.SYMBOLIC);
     },
 
     open: function() {
index 5a20e7c7b8307b931d2539242bea834939105be0..4d9035df0d16c5f7575f40bae62f8a5a4cfdd90e 100644 (file)
@@ -638,5 +638,10 @@ const Source = new Lang.Class({
         }
 
         this.parent();
+    },
+
+    createNotificationIcon: function() {
+        // We set the summary icon ourselves.
+        return null;
     }
 });
index 93f9d9c3b5809a7ebf39b019c82e012e5f556653..6a44a247d429abdd046b5bc9b89155d8c0e4ddb0 100644 (file)
@@ -243,6 +243,7 @@ const ShellMountPasswordSource = new Lang.Class({
         this.parent(strings[0]);
 
         this._notification = new ShellMountPasswordNotification(this, strings, icon, reaskPassword);
+        this._setSummaryIcon(icon);
 
         // add ourselves as a source, and popup the notification
         Main.messageTray.add(this);
index c671e6b656ea7bfe8fa9e3a5b4c54854a08793b6..8342ab136500f7d7616361dd3fbeb01df75d509c 100644 (file)
@@ -305,7 +305,7 @@ const Indicator = new Lang.Class({
 
     _ensureSource: function() {
         if (!this._source) {
-            this._source = new Source();
+            this._source = new MessageTray.Source(_("Bluetooth"), 'bluetooth-active', St.IconType.SYMBOLIC);
             Main.messageTray.add(this._source);
         }
     },
@@ -330,35 +330,6 @@ const Indicator = new Lang.Class({
     }
 });
 
-const Source = new Lang.Class({
-    Name: 'BluetoothSource',
-    Extends: MessageTray.Source,
-
-    _init: function() {
-        this.parent(_("Bluetooth"));
-
-        this._setSummaryIcon(this.createNotificationIcon());
-    },
-
-    notify: function(notification) {
-        this._private_destroyId = notification.connect('destroy', Lang.bind(this, function(notification) {
-            if (this.notification == notification) {
-                // the destroyed notification is the last for this source
-                this.notification.disconnect(this._private_destroyId);
-                this.destroy();
-            }
-        }));
-
-        this.parent(notification);
-    },
-
-    createNotificationIcon: function() {
-        return new St.Icon({ icon_name: 'bluetooth-active',
-                             icon_type: St.IconType.SYMBOLIC,
-                             icon_size: this.ICON_SIZE });
-    }
-});
-
 const AuthNotification = new Lang.Class({
     Name: 'AuthNotification',
     Extends: MessageTray.Notification,
index dedd4a49941ad77bd45de966e1ea10bee67e3b1c..46e9da90e4c8aa6ef7bed2b6529b415262738358 100644 (file)
@@ -1644,7 +1644,10 @@ const NMApplet = new Lang.Class({
 
     _ensureSource: function() {
         if (!this._source) {
-            this._source = new NMMessageTraySource();
+            this._source = new MessageTray.Source(_("Network Manager"),
+                                                  'network-transmit-receive',
+                                                  St.IconType.SYMBOLIC);
+
             this._source.connect('destroy', Lang.bind(this, function() {
                 this._source = null;
             }));
@@ -2100,18 +2103,3 @@ const NMApplet = new Lang.Class({
         }
     }
 });
-
-const NMMessageTraySource = new Lang.Class({
-    Name: 'NMMessageTraySource',
-    Extends: MessageTray.Source,
-
-    _init: function() {
-        this.parent(_("Network Manager"));
-
-        let icon = new St.Icon({ icon_name: 'network-transmit-receive',
-                                 icon_type: St.IconType.SYMBOLIC,
-                                 icon_size: this.ICON_SIZE
-                               });
-        this._setSummaryIcon(icon);
-    }
-});
index b705c7ad5b8ea96c85535bde4692ceeb8acb4b45..c38b3f79d64ddea7811a2c3c63fb79271af15fba 100644 (file)
@@ -365,8 +365,9 @@ const Client = new Lang.Class({
 
     _ensureSubscriptionSource: function() {
         if (this._subscriptionSource == null) {
-            this._subscriptionSource = new MultiNotificationSource(
-                _("Subscription request"), 'gtk-dialog-question');
+            this._subscriptionSource = new MessageTray.Source(_("Subscription request"),
+                                                              'gtk-dialog-question',
+                                                              St.IconType.FULLCOLOR);
             Main.messageTray.add(this._subscriptionSource);
             this._subscriptionSource.connect('destroy', Lang.bind(this, function () {
                 this._subscriptionSource = null;
@@ -401,8 +402,9 @@ const Client = new Lang.Class({
 
     _ensureAccountSource: function() {
         if (this._accountSource == null) {
-            this._accountSource = new MultiNotificationSource(
-                _("Connection error"), 'gtk-dialog-error');
+            this._accountSource = new MessageTray.Source(_("Connection error"),
+                                                         'gtk-dialog-error',
+                                                         St.IconType.FULLCOLOR);
             Main.messageTray.add(this._accountSource);
             this._accountSource.connect('destroy', Lang.bind(this, function () {
                 this._accountSource = null;
@@ -418,14 +420,14 @@ const ChatSource = new Lang.Class({
     Extends: MessageTray.Source,
 
     _init: function(account, conn, channel, contact, client) {
-        this.parent(contact.get_alias());
-
         this.isChat = true;
 
         this._account = account;
         this._contact = contact;
         this._client = client;
 
+        this.parent(contact.get_alias());
+
         this._pendingMessages = [];
 
         this._conn = conn;
@@ -446,8 +448,6 @@ const ChatSource = new Lang.Class({
         this._receivedId = this._channel.connect('message-received', Lang.bind(this, this._messageReceived));
         this._pendingId = this._channel.connect('pending-message-removed', Lang.bind(this, this._pendingRemoved));
 
-        this._setSummaryIcon(this.createNotificationIcon());
-
         this._notifyAliasId = this._contact.connect('notify::alias', Lang.bind(this, this._updateAlias));
         this._notifyAvatarId = this._contact.connect('notify::avatar-file', Lang.bind(this, this._updateAvatarIcon));
         this._presenceChangedId = this._contact.connect('presence-changed', Lang.bind(this, this._presenceChanged));
@@ -1002,10 +1002,9 @@ const ApproverSource = new Lang.Class({
     Extends: MessageTray.Source,
 
     _init: function(dispatchOp, text, gicon) {
-        this.parent(text);
-
         this._gicon = gicon;
-        this._setSummaryIcon(this.createNotificationIcon());
+
+        this.parent(text);
 
         this._dispatchOp = dispatchOp;
 
@@ -1028,7 +1027,6 @@ const ApproverSource = new Lang.Class({
 
     createNotificationIcon: function() {
         return new St.Icon({ gicon: this._gicon,
-                             icon_type: St.IconType.FULLCOLOR,
                              icon_size: this.ICON_SIZE });
     }
 });
@@ -1151,40 +1149,6 @@ const FileTransferNotification = new Lang.Class({
     }
 });
 
-// A notification source that can embed multiple notifications
-const MultiNotificationSource = new Lang.Class({
-    Name: 'MultiNotificationSource',
-    Extends: MessageTray.Source,
-
-    _init: function(title, icon) {
-        this.parent(title);
-
-        this._icon = icon;
-        this._setSummaryIcon(this.createNotificationIcon());
-        this._nbNotifications = 0;
-    },
-
-    notify: function(notification) {
-        this.parent(notification);
-
-        this._nbNotifications += 1;
-
-        // Display the source while there is at least one notification
-        notification.connect('destroy', Lang.bind(this, function () {
-            this._nbNotifications -= 1;
-
-            if (this._nbNotifications == 0)
-                this.destroy();
-        }));
-    },
-
-    createNotificationIcon: function() {
-        return new St.Icon({ gicon: Gio.icon_new_for_string(this._icon),
-                             icon_type: St.IconType.FULLCOLOR,
-                             icon_size: this.ICON_SIZE });
-    }
-});
-
 // Subscription request
 const SubscriptionRequestNotification = new Lang.Class({
     Name: 'SubscriptionRequestNotification',
index e503de46b39b075023169ddf282b34433be18239..9a2dd73e706c843ff7674a4c353f7e7ae572e27e 100644 (file)
@@ -53,10 +53,10 @@ const Source = new Lang.Class({
     Extends: MessageTray.Source,
 
     _init: function(app, window) {
-        this.parent(app.get_name());
         this._window = window;
         this._app = app;
-        this._setSummaryIcon(this.createNotificationIcon());
+
+        this.parent(app.get_name());
 
         this.signalIDs = [];
         this.signalIDs.push(this._window.connect('notify::demands-attention', Lang.bind(this, function() { this.destroy(); })));